home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / Types.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  6.6 KB  |  325 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Types.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __TYPES__
  18. #define __TYPES__
  19.  
  20.  
  21. #ifndef __CONDITIONALMACROS__
  22. #include <ConditionalMacros.h>
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. #if GENERATINGPOWERPC
  30. #pragma options align=mac68k
  31. #endif
  32.  
  33. #ifdef __CFM68K__
  34. #pragma lib_export on
  35. #endif
  36.  
  37. #ifndef NULL
  38. #if !defined(__cplusplus) && (defined(__SC__) || defined(THINK_C))
  39. #define NULL ((void *) 0)
  40. #else
  41. #define NULL 0
  42. #endif
  43. #endif
  44. #ifndef nil
  45. #define nil NULL
  46. #endif
  47.  
  48. enum {
  49.     noErr                        = 0
  50. };
  51.  
  52. typedef unsigned char Byte;
  53.  
  54. typedef char SignedByte;
  55.  
  56. typedef Byte UInt8;
  57.  
  58. typedef SignedByte SInt8;
  59.  
  60. typedef unsigned short UInt16;
  61.  
  62. typedef signed short SInt16;
  63.  
  64. typedef unsigned long UInt32;
  65.  
  66. typedef signed long SInt32;
  67.  
  68. typedef SignedByte *Ptr;
  69.  
  70. /*  pointer to a master pointer */
  71. typedef Ptr *Handle;
  72.  
  73. typedef long Fixed;
  74.  
  75. typedef Fixed *FixedPtr;
  76.  
  77. typedef long Fract;
  78.  
  79. typedef Fract *FractPtr;
  80.  
  81. struct _extended80 {
  82.     short                            exp;
  83.     short                            man[4];
  84. };
  85. struct _extended96 {
  86.     short                            exp[2];
  87.     short                            man[4];
  88. };
  89. #if GENERATING68K 
  90. #if defined(__MWERKS__)
  91. // Note: Metrowerks on 68K doesn't declare 'extended' or 'comp' implicitly. 
  92. typedef long double extended;
  93. typedef struct comp { long hi,lo; } comp;
  94.  
  95. #elif defined(THINK_C)
  96. // Note: THINK C doesn't declare 'comp' implicitly and needs magic for 'extended' 
  97. typedef struct { short man[4]; } comp;
  98. typedef struct _extended80 __extended;    //  <-- this line is magic
  99. typedef __extended extended;
  100.  
  101. #endif
  102. /* 
  103. Note: on PowerPC extended is undefined.
  104.       on 68K when mc68881 is on, extended is 96 bits.  
  105.              when mc68881 is off, extended is 80 bits.  
  106.       Some old toolbox routines require an 80 bit extended so we define extended80
  107. */
  108. #if GENERATING68881
  109. typedef struct _extended80 extended80;
  110.  
  111. typedef extended extended96;
  112.  
  113. #else
  114. typedef extended extended80;
  115.  
  116. typedef struct _extended96 extended96;
  117.  
  118. #endif
  119. #else
  120. typedef struct _extended80 extended80;
  121.  
  122. typedef struct _extended96 extended96;
  123.  
  124. #endif
  125. /*
  126. Note: float_t and double_t are "natural" computational types
  127.       (i.e.the compiler/processor can most easily do floating point
  128.       operations with that type.) 
  129. */
  130. #if GENERATINGPOWERPC
  131. /* on PowerPC, double = 64-bit which is fastest.  float = 32-bit */
  132. typedef float float_t;
  133.  
  134. typedef double double_t;
  135.  
  136. #else
  137. /* on 68K, long double (a.k.a. extended) is always the fastest.  It is 80 or 96-bits */
  138. typedef long double float_t;
  139.  
  140. typedef long double double_t;
  141.  
  142. #endif
  143. struct wide {
  144.     SInt32                            hi;
  145.     UInt32                            lo;
  146. };
  147. typedef struct wide wide, *WidePtr;
  148.  
  149. struct UnsignedWide {
  150.     UInt32                            hi;
  151.     UInt32                            lo;
  152. };
  153. typedef struct UnsignedWide UnsignedWide, *UnsignedWidePtr;
  154.  
  155. #if defined(__SC__) && !defined(__STDC__) && defined(__cplusplus)
  156.     class __machdl HandleObject {};
  157. #if !GENERATINGPOWERPC
  158.     class __pasobj PascalObject {};
  159. #endif
  160. #endif
  161.  
  162. enum {
  163.     false,
  164.     true
  165. };
  166.  
  167. typedef unsigned char Boolean;
  168.  
  169.  
  170. enum {
  171.     v,
  172.     h
  173. };
  174.  
  175. typedef SInt8 VHSelect;
  176.  
  177. typedef long (*ProcPtr)();
  178. typedef pascal void (*Register68kProcPtr)(void);
  179. typedef ProcPtr *ProcHandle;
  180.  
  181. #if    GENERATINGCFM
  182. typedef struct RoutineDescriptor *UniversalProcPtr, **UniversalProcHandle;
  183.  
  184. #else
  185. typedef ProcPtr UniversalProcPtr, *UniversalProcHandle;
  186.  
  187. #endif
  188. typedef unsigned char Str255[256], Str63[64], Str32[33], Str31[32], Str27[28], Str15[16];
  189.  
  190. typedef unsigned char *StringPtr, **StringHandle;
  191.  
  192. /* A C string is a zero terminated array of bytes.  There is no length byte.
  193.     a CStringPtr is a pointer to a C string (e.g. char* )
  194.     a ConstCStringPtr is a CStringPtr whose contents cannot be changed (e.g. const char* )
  195. */
  196. typedef const unsigned char *ConstStr255Param;
  197.  
  198. typedef ConstStr255Param ConstStr63Param, ConstStr32Param, ConstStr31Param, ConstStr27Param, ConstStr15Param;
  199.  
  200. #ifdef __cplusplus
  201. inline unsigned char StrLength(ConstStr255Param string) { return (*string); }
  202. #else
  203. #define StrLength(string) (*(unsigned char *)(string))
  204. #endif
  205. #if OLDROUTINENAMES
  206. #define Length(string) StrLength(string)
  207. #endif
  208. typedef short OSErr;
  209.  
  210. typedef short ScriptCode;
  211.  
  212. typedef short LangCode;
  213.  
  214. typedef unsigned long FourCharCode;
  215.  
  216.  
  217. enum {
  218.     normal                        = 0,
  219.     bold                        = 1,
  220.     italic                        = 2,
  221.     underline                    = 4,
  222.     outline                        = 8,
  223.     shadow                        = 0x10,
  224.     condense                    = 0x20,
  225.     extend                        = 0x40
  226. };
  227.  
  228. typedef unsigned char Style;
  229.  
  230. typedef FourCharCode OSType;
  231.  
  232. typedef FourCharCode ResType;
  233.  
  234. typedef OSType *OSTypePtr;
  235.  
  236. typedef ResType *ResTypePtr;
  237.  
  238. struct Point {
  239.     short                            v;
  240.     short                            h;
  241. };
  242. typedef struct Point Point;
  243.  
  244. typedef Point *PointPtr;
  245.  
  246. struct Rect {
  247.     short                            top;
  248.     short                            left;
  249.     short                            bottom;
  250.     short                            right;
  251. };
  252. typedef struct Rect Rect;
  253.  
  254. typedef Rect *RectPtr;
  255.  
  256. /* Numeric version part of 'vers' resource */
  257. struct NumVersion {
  258.     UInt8                            majorRev;                    /*1st part of version number in BCD*/
  259.     UInt8                            minorAndBugRev;                /*2nd & 3rd part of version number share a byte*/
  260.     UInt8                            stage;                        /*stage code: dev, alpha, beta, final*/
  261.     UInt8                            nonRelRev;                    /*revision level of non-released version*/
  262. };
  263. typedef struct NumVersion NumVersion;
  264.  
  265. /* 'vers' resource format */
  266. struct VersRec {
  267.     NumVersion                        numericVersion;                /*encoded version number*/
  268.     short                            countryCode;                /*country code from intl utilities*/
  269.     Str255                            shortVersion;                /*version number string - worst case*/
  270.     Str255                            reserved;                    /*longMessage string packed after shortVersion*/
  271. };
  272. typedef struct VersRec VersRec;
  273.  
  274. typedef VersRec *VersRecPtr, **VersRecHndl;
  275.  
  276. extern pascal void Debugger(void)
  277. #if GENERATING68K
  278.  = 0xA9FF
  279. #endif
  280.  ;
  281.  
  282. /* Note: the 0xA9FF and 0xABFF traps are conditionally inlined in a different manner 
  283.          so that CFM 68K applications can use them */
  284. extern pascal void DebugStr(ConstStr255Param debuggerMsg)
  285. #if GENERATING68K
  286.  = 0xABFF
  287. #endif
  288.  ;
  289.  
  290. extern pascal void Debugger68k(void)
  291. #if GENERATING68K
  292.  = 0xA9FF
  293. #endif
  294.  ;
  295.  
  296. extern pascal void DebugStr68k(ConstStr255Param debuggerMsg)
  297. #if GENERATING68K
  298.  = 0xABFF
  299. #endif
  300.  ;
  301.  
  302. #if CGLUESUPPORTED
  303. extern void debugstr(const char *debuggerMsg);
  304. #endif
  305. extern pascal void SysBreak(void)
  306.  THREEWORDINLINE(0x303C, 0xFE16, 0xA9C9);
  307. extern pascal void SysBreakStr(ConstStr255Param debuggerMsg)
  308.  THREEWORDINLINE(0x303C, 0xFE15, 0xA9C9);
  309. extern pascal void SysBreakFunc(ConstStr255Param debuggerMsg)
  310.  THREEWORDINLINE(0x303C, 0xFE14, 0xA9C9);
  311.  
  312. #ifdef __CFM68K__
  313. #pragma lib_export off
  314. #endif
  315.  
  316. #if GENERATINGPOWERPC
  317. #pragma options align=reset
  318. #endif
  319.  
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323.  
  324. #endif /* __TYPES__ */
  325.